﻿#include "Dialog.h"
//#include "Game.h"
Dialog::Dialog(void):CCNode()
{
	CCSize winSize = CCSizeMake(320,480);
	cocos2d::CCSprite* sp1;
    cantouch=false;
    /*sp1 = CCSprite::create("fengmian.png");

	sp1->setPosition(ccp(winSize.width/2,winSize.height/2));
	//sp1->setAnchorPoint(cocos2d::CCPointZero);
	this->addChild(sp1, 0, -1);*/
	this->runAction(CCSequence::create(CCDelayTime::create(2),
                                       
                                       CCCallFunc::create(this, callfunc_selector(Dialog::enableTouch)),NULL));

}

Dialog::~Dialog(void)
{
}


void Dialog::onEnter()
{
    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, -100, true);
	CCNode::onEnter();
}

void Dialog::onExit()
{
	CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(this);
	CCNode::onExit();
}	


bool Dialog::ccTouchBegan(CCTouch* touch, CCEvent* event)
{
    if(cantouch)
    {
        this->getParent()->removeChild(this);
    }
	return true;
}

void Dialog::ccTouchMoved(CCTouch* touch, CCEvent* event)
{

}

void Dialog::ccTouchEnded(CCTouch* touch, CCEvent* event)
{
} 

void Dialog::touchDelegateRetain()
{
	this->retain();
}

void Dialog::touchDelegateRelease()
{
	this->release();
}

void Dialog::enableTouch(CCObject *pSender) {
	cantouch=true;
}